package ru.ifmo.itmokis.algo;

import ru.ifmo.itmokis.util.Config;

/**
 *
 * @author Ivan Stepuk
 */
public class Normalizer {

    private Config config;
    // ^ Dependencies ^
    public static final int CRITERIA_SUM = 100;
    private int maxProduced;
    private int maxFailed;
    private int maxChangeovers;

    public Normalizer(Config config) {
        this.config = config;
    }

    public void reconfigure(int maxProduced, int maxFailed, int maxChangeovers) {
        this.maxProduced = maxProduced;
        this.maxFailed = maxFailed;
        this.maxChangeovers = maxChangeovers;
    }

    public double normalize(Stats stats) {
        double a = 1 - stats.getProduced() / (double) maxProduced;
        double b = stats.getFailed() / (double) maxFailed;
        double c = stats.getChangeovers() / (double) maxChangeovers;
        return (config.getInt("A") * a + config.getInt("B") * b + config.getInt("C") * c) / CRITERIA_SUM;
    }
}
